cd "C:\Users\49669\Desktop\小论文\计量数据\数据"
use all,clear
gen case1=1
replace case1=0 if case==0  
describe
tab case1
sum case1 landlord price age plot household floor market hospital subway shopping 品牌
gen lprice=ln(price)
gen lhousehold=ln(household)
gen	lhospital=ln(hospital)
gen	lsubway=ln(subway)
gen	lshopping=ln(shopping)
sum case1 landlord lprice age plot lhousehold floor  lhospital lsubway lshopping
reg case1 landlord lprice age plot lhousehold floor  lhospital lsubway lshopping,robust
estat vif // 方差膨胀因子
ovtest //内生性，是否存在遗漏变量
ivregress 2sls case1 (landlord = floor age) price plot household market hospital subway shopping,robust
estat overid // 过度识别
estat firststage, all forcenonrobust // 工具变量与内生变量相关性
ivregress liml case1 (landlord = floor age) price plot household market hospital subway shopping,robust
qui reg case1 landlord price plot household elevator market hospital subway shopping
estimates store ols
qui ivregress 2sls case1 (landlord = floor age) price plot household market hospital subway shopping
estimates store iv
hausman iv ols, constant sigmamore // hausman检验
estat endogenous //内生性

logit case1 landlord lprice age plot lhousehold floor lhospital lsubway lshopping, or robust
estat class
margins, dydx(*)
outreg2 using 1.doc,replace ctitle(logit)
listcoef, help constant //自变量变动一个单位时的胜算比
logit case1 landlord,  robust
logit case1 landlord lprice age plot lhousehold elevator floor 品牌 lhospital lsubway lshopping,  robust
margins, dydx(*) post
outreg2 using 21.doc,replace ctitle(logit)
fitstat
qui logit case1 landlord lprice age plot lhousehold elevator floor 品牌 lhospital lsubway lshopping,or robust
estat class // 预测百分比
test landlord price plot household elevator market hospital shopping // wald联合显著性检验
lfit // 拟合优度检验，P值越大拟合优度越好
lstat //回归后的分类结果
lsens //寻找最佳临界值
lroc //使用ROC评估回归效果,预测值为1的准确率与错误率的散点图

 


poisson case landlord lprice age plot lhousehold elevator floor 品牌 lhospital lsubway lshopping, robust
outreg2 using o.doc,replace ctitle(poisson 1)	
probit case landlord lprice age plot lhousehold elevator floor 品牌 lhospital lsubway lshopping, robust
outreg2 using p.doc,replace ctitle(probit)

heckman case1 landlord lprice age plot lhousehold floor market lhospital lsubway lshopping,select(landlord lprice age plot lhousehold floor market lhospital lsubway lshopping)twostep

heckman case landlord lprice age plot lhousehold floor  lhospital lsubway lshopping,select(case1=landlord lprice age plot lhousehold floor  lhospital lsubway lshopping)twostep
